/**
 * Serializer
 * 坐标均相对于编辑窗口    坐标单位：mm
 */
if(typeof (module) !="undefined"){
    module.exports = Parser; // 继承第1/2步（基类）：导出

    var Serializer = require('./Serializer');
    var FileObj = require('./FileObj');
    var ImageObj = require('./ImageObj');
    var GraphObj = require('./GraphObj');
    var TableObj = require('./TableObj');
    var GroupObj = require('./GroupObj');
    var FrameObj = require('./FrameObj');
    var TextObj = require('./TextObj');
    var SubTemplateObj = require('./SubTemplateObj');
    var TextTableObj= require('./TextTableObj');
    var PrintPage = require('./PrintPage');
    var LayerObj = require('./LayerObj');
    var PdfObj = require('./PdfObj');
}


function Parser()
{

}


// 从一个未知json对象中，解析出对应Obj(在文档初始化的时候使用)
Parser.prototype.fromUnknownJson = function(jsonObj, versionId){
    var ret = null;
    switch(jsonObj.ct){
        case Serializer.prototype.CLASS_TYPE_FILEOBJ:// FileObj类型
            ret = new FileObj();
            break;
        case Serializer.prototype.CLASS_TYPE_IMAGEOBJ:// ImageObj类型
            ret = new ImageObj();
            break;
        case Serializer.prototype.CLASS_TYPE_GRAPHOBJ:// GraphObj类型
            ret = new GraphObj();
            break;
        case Serializer.prototype.CLASS_TYPE_TABLEOBJ:// TableObj类型
            ret = new TableObj();
            break;
        case Serializer.prototype.CLASS_TYPE_FRAMEOBJ:// FrameObj类型
            ret = new FrameObj();
            break;
        case Serializer.prototype.CLASS_TYPE_GROUPOBJ:// GroupObj类型
            ret = new GroupObj();
            break;
        case Serializer.prototype.CLASS_TYPE_TEXTOBJ:// TextObj类型
            ret = new TextObj();
            break;
        case Serializer.prototype.CLASS_TYPE_SUBTEMPLATEOBJ: // SubTemplateObj类型
            ret = new SubTemplateObj();
            break;
        case Serializer.prototype.CLASS_TYPE_TEXTTABLEOBJ:// TextTableObj类型
            ret = new TextTableObj();
            break;
        case Serializer.prototype.CLASS_TYPE_PRINTPAGE:// PrintPage类型
            ret = new PrintPage();
            break;
        case Serializer.prototype.CLASS_TYPE_LAYEROBJ : // LayerObj类型
            ret = new LayerObj();
            break;
        case Serializer.prototype.CLASS_TYPE_PDFOBJ: // PDFObj类型
            ret = new PdfObj();
            break;
        default:
            break;
    }
    ret.fromJson(jsonObj,versionId);
//    var str1 = JSON.stringify(jsonObj);
//    console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@"+str1);
    return ret;
}



